home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / patches / patch2amitcp_4.3 / patch / amitcp / ssrx / commandstate.ssrx < prev    next >
Encoding:
Text File  |  1996-03-30  |  1.9 KB  |  101 lines

  1. /*
  2.  *    $Id$
  3.  *
  4.  *    AmiTCP/IP Dial Script Subroutine to put the modem to
  5.  *    command state.
  6.  *
  7.  *    Copyright © 1995 AmiTCP/IP Group,
  8.  *                     Network Solutions Development Inc.
  9.  *                     All rights reserved.
  10.  * 
  11.  *      
  12.  */
  13.  
  14. /*
  15.  * Set Inter-character delay to 100 ms.
  16.  * Some modems need this.
  17.  */
  18. options results
  19.  
  20. Set InterCharDelay 100
  21. OldDelay = result /* save the old value */
  22.  
  23. /*
  24.  * Set the WaitFor timeout to 2 seconds.
  25.  * Modem needs to respond in this time.
  26.  */
  27. Set WaitForTimeout 2
  28. OldTimeOut = result  /* save the old value */
  29.  
  30. /* enable error signal */
  31. signal on error
  32. Status "Putting modem to the command state..."
  33.  
  34. ModemOnline NO  /* Do not use Carrier Detect if configured (yet) */
  35.  
  36. /* Initialize variables */
  37. onCommandState = 0  /* Assume not in command state */
  38. retries = 0
  39. maxRetries = 10
  40.  
  41. Flush  /* Flush old input from serial */
  42.  
  43. do until onCommandState
  44.   /*
  45.    * Test if the modem is in the command state
  46.    */
  47.   if (retries // 3 = 0) then do /* Output null command first */
  48.     SendLn ""
  49.     SendLn ""
  50.     SendLn "AT"
  51.   end
  52.  
  53.   WaitFor! "OK\r\n"
  54.   res = result        /* Save WaitFor's RC */
  55.  
  56.   if (res = 1) then do
  57.     onCommandState = 1
  58.   end
  59.   else do
  60.     if (retries > maxRetries) then do
  61.       Status "Could not put modem to command state."
  62.       exit 10
  63.     end
  64.     retries = retries + 1
  65.     /*
  66.      * Send three '+' chars to put the modem to the 
  67.      * command state
  68.      */
  69.     Set InterCharDelay 1000    
  70.     Pause 1
  71.     Send '+++'
  72.     Set InterCharDelay 100    
  73.   end
  74. end
  75.  
  76. Status "Initializing modem"
  77.  
  78. /*
  79.  * &F  - reset to factory defaults
  80.  * &C1 - enable carrier detect
  81.  * &D2 - disconnect if DTR drops
  82.  * &K3
  83.  * X3 - blind dial, recognize BUSY, report baud rate with CONNECT
  84.  */
  85.  
  86. Get ModemInitString
  87. SendLn ModemInitString
  88. WaitFor "OK"
  89.  
  90. /*
  91.  * return old values
  92.  */
  93. Set WaitForTimeout OldTimeOut
  94. Set InterCharDelay OldDelay
  95. Status "Succeeded."
  96. exit 0
  97.  
  98. error:
  99. Say "CommandState.adrx: Command on line" SIGL "returned" RC ":" SerScript.LASTERROR
  100. Exit 10
  101.